package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-03-12
 * Time: 21:53
 */
public class BorrowedOperation implements IOperation{
    public void work(BookList bookList) {
        System.out.println("...借阅图书...");
        System.out.print("请输入你要借阅的书：");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = bookList.getUseSize();
        int i = 0;
        for(; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            if(name.equals(book.getName())) {
                book.setLend(true);
                System.out.println("借阅成功!");
                return;
            }
        }
        System.out.println("没有这本书，借阅失败！");
    }
}
